<template>
	<view>
		<ss-calendar :checks="checks" @current-month-day="onSignIn" @prev-month-day="onPrev" @next-month-day="onNext" />
		<button style="width: 80%; margin: 40rpx auto;background: #5990FF;color: #FFFFFF;" class="add-btn" @click="qd()">{{titleName}}</button>
	</view>
</template>

<script>
	import ssCalendar from '@/pageB/components/ss-calendar/ss-calendar.vue'
	export default {
		components: {
			ssCalendar
		},
		data() {
			return {
				checks: [],
				titleName:""
			};
		},
		onLoad(options) {
			this.titleName = options.name
			uni.setNavigationBarTitle({
				title:options.name
			})
			this.getList()
		},
		methods: {
			onSignIn(payload) {
				const {
					checked,
					year,
					month,
					day
				} = payload

					!checked && this.checks.push(`${year}-${month}-${day}`)

				console.log('onSignIn', payload)
			},
			onPrev(payload) {
				console.log('onPrev', payload)
			},
			onNext(payload) {
				console.log('onNext', payload)
			},
			getList(){
				this.$fun.ajax.post('user/signInfo',{}).then(res=>{
					if(res.code==1){
						this.checks = res.data
					}
				})
			},
			qd(){
				this.$fun.ajax.post('user/signin',{}).then(res=>{
					this.$fun.msg(res.msg)
						if(res.code ==1){
							setTimeout(()=>{
								this.getList()
							},800)
						}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	page{
		width: 100vw;
		height: 100vh;
		// background: url('/static/temp/26b41754dbe3f1ccb5d2bee1220863b.jpg') no-repeat;
		background-size: 100vw 100vh ;
	}
</style>
